<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="common/include :: header('服务项列表')" />
</head>
<style>
    #real{
        /*点击弹出模态框的图片*/
        margin: 30px;
        width: 250px;
        border-radius:6px;
    }
    #real:hover{
        opacity: 0.6;
    }
    #mo{
        display: none;/*隐藏*/
        width: 100%;
        height: 100%;
        position: fixed;
        overflow: auto;
        background-color: rgba(0,0,0,0.7);
        top: 0px;
        left: 0px;
        z-index: 1;
    }
    #moimg{
        display: block;
        margin:25px auto;
        width: 60%;
        max-width: 750px;
    }
    #caption{
        text-align: center;
        margin: 15px auto;
        width: 60%;
        max-height: 750px;
        font-size: 20px;
        color:#ccc;
    }
    #moimg,#caption{
        -webkit-animation: first 1s;
        -o-animation: first 1s;
        animation: first 1s;
    }
    @keyframes first{
        from{transform: scale(0.1);}
        to{transform: scale(1);}
    }
    .close{
        font-size: 40px;
        font-weight: bold;
        position: absolute;
        top: 20px;
        right: 14%;
        color:#f1f1f1;
    }
    .close:hover,
    .close:focus{
        color:#bbb;
        cursor:pointer;
    }
    @media only screen and(max-750px ) {
        #moimg{
            width: 100%;
        }
    }
</style>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="post-form">
					<div class="select-list">
						<ul>
							<li>
								关键字：<input type="text" name="keyword"/>
							</li>
							<li>
								仓库：
								<select name="storeId" th:with="type=${@dict.getType('si_car_package')}">
									<option value="">所有</option>
									<option th:each="store:${stores}" th:value="${store.id}" th:text="${store.storeName}"></option>
								</select>
							</li>
							<li>
								分类：
								<select name="categoryId" >
									<option value="">所有</option>
									<option th:each="goodsCategorie:${goodsCategories}" th:value="${goodsCategorie.id}" th:text="${goodsCategorie.categoryName}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:post:add">
	                <i class="fa fa-plus"></i> 添加物品
	            </a>
				<a class="btn btn-warning " id="startAudit" onclick="toStore()" shiro:hasPermission="system:post:add">
					<i class="fa fa-plus"></i> 仓库管理
				</a>
				<a class="btn btn-warning " id="ss" onclick="toGoodsCategory()" shiro:hasPermission="system:post:add">
					<i class="fa fa-plus"></i> 分类管理
				</a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
            <!--图片模态框 -->
            <div class="motai" id="mo">
                <span class="close" id="close">×</span>
                <img class="motaiimg" id="moimg" src="">
                <div id="caption"></div>
            </div>
		</div>
	</div>
	<th:block th:include="common/include :: footer" />
	<th:block th:include="common/include :: ztree" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('system:post:edit')}]];
		var removeFlag = [[${@permission.hasPermi('system:post:remove')}]];
		var categoryData = [[${@dict.getType('bus_goods_classify')}]];

		var prefix = ctx + "/business/goods";
		$(function() {
		    var options = {
		        url: prefix + "/query",
		        createUrl: prefix + "/addPage",
		        updateUrl: prefix + "/editPage?id={id}",
		        removeUrl: prefix + "/remove?id={id}",
		        exportUrl: prefix + "/export",
		        modalName: "商品",
		        columns: [
		        {
		            field: 'id',
		            title: '序号',
					visible: true,
                    formatter:function (value,row,index) {
                        //获取每页显示的数量
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
		        },
				{
					field: 'goodsCover',
					title: '物品',
					visible: true,
					formatter: function(value, row, index) {
						return '<a href="#" onclick="showImg('+row.id+')" ><img id="'+row.id+'" src="'+value+'" width="20px" height="20px"></a>';
					}
				},
		        {
		            field: 'goodsName',
		            title: '名称',
		            sortable: true
		        },

		        {
		            field: 'brand',
		            title: '品牌',
		            sortable: true
		        },
		        {
		            field: 'goodsCategory.categoryName',
		            title: '分类',
		            sortable: true,
		        },
				{
					field: 'goodsStore.amounts',
					title: '数量',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
						actions.push('<a class="btn btn-success  btn-xs " href="javascript:void(0)" ' +
								'onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-info  btn-xs " href="javascript:void(0)" ' +
									'onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');

							actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" ' +
									'onclick="goodsItem(\'' + row.id + '\')"><i class="fa fa-edit"></i>出入库明细</a> ');
		                return actions.join('');
		            }
		        }]


		    };
		    $.table.init(options);


		});


		function toStore() {
			$.modal.openTab("仓库管理","/business/store/listPage");
		}
		function toGoodsCategory() {
			$.modal.openTab("物品分类","business/goodsCategory/listPage");
		}

        var motai=document.getElementById('mo');
        var moimg=document.getElementById("moimg");
        var caption=document.getElementById("caption");
		function showImg(id) {
            $.operate.get('/business/goods/readResource?id='+id,function (result) {
                console.log(result);
                motai.style.display="block";
                moimg.src=result.data;
            });
		}

        var span=document.getElementById("close");
        span.onclick=function(){
            motai.style.display="none";
        }

        function goodsItem(id) {
			$.modal.openTab("出入库明细","/business/goods/goodsItemPage?id="+id);
		}
	</script>
</body>
</html>